﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kaspersky.Test.RecursiveLinkLogger
{
    /// <summary>
    /// Searches for HTML links in a string using a custom state machine.
    /// Doesn't want 'http://' prefix.
    /// </summary>
    public class StateMachineLinkExtractor : ILinkExtractor
    {
        public IEnumerable<string> ExtractLinksFromString(string s)
        {
            var result = new List<string>();

            var stateMachine = new LinkParsingStateMachine();
            stateMachine.LinkFoundEvent += result.Add;
            stateMachine.Parse(s);

            return result;
        }
    }
}
